import request from '@/utils/request'

//API常量
const APIS = {
    V1: "/v1"
}

export function listFileByProjecId(data) {
    return request({
        url: APIS.V1 + `/system/projectFile/listFileByProjecId`,
        method: 'post',
        data
    })
}

export function createProjectFile(data) {
  return request({
    url: APIS.V1+`/system/projectFile/saveFile`,
    method: 'post',
    data
  })
}

export function updateProjectFile(data) {
  return request({
    url: APIS.V1+`/system/projectFile/updateFile`,
    method: 'post',
    data
  })
}

export function findByProjectIdAndFileType(params) {
    return request({
        url: APIS.V1 + `/system/projectFile/findByProjectIdAndFileType`,
        method: 'get',
        params: params
    })
}

export function deleteProjectFile(params) {
    return request({
        url: APIS.V1 + `/system/projectFile/deleteByFileId`,
        method: 'delete',
        params: params
    })
}


//资方信息栏
export function capitalMatch(params) {
  return request({
      url: APIS.V1 + `/system/product/match`,
      method: 'get',
      params: params
  })
}


//资方匹配列表
export function caitalList(params) {
  return request({
    url: APIS.V1 + `/system/capital/match/list`,
    method:'get',
    params: params
  })
}

//资方匹配列表
export function caitalSelect(data) {
  return request({
    url: APIS.V1 + `/system/capital/match/selected`,
    method:'post',
    data: data
  })
}

//审批附件上传
export function createApprovalFile(data) {
  return request({
    url: APIS.V1+`/system/approval/conclusion/upload`,
    method: 'post',
    data
  })
}

//审批附件批量下载
export function exportFile(data,callback1) {
  return request({
    url: APIS.V1+`/system/projectFile/download`,
    method: 'post',
    data,
    onDownloadProgress:(progressEvent) => { //原生获取上传进度的事件
      // console.log('22')
      // console.log(progressEvent,'progressEvent')
        if(progressEvent.lengthComputable){
            //属性lengthComputable主要表明总共需要完成的工作量和已经完成的工作是否可以被测量
            //如果lengthComputable为false，就获取不到progressEvent.total和progressEvent.loaded
           return callback1(progressEvent);
        }
    },
    responseType: 'blob',
    timeout: 500000000 * 2,
  })
}

const uploadPath = process.env.VUE_APP_BASE_API + '/v1/system/file/upload'
export { uploadPath }
